package org.wenhuayuan.project.main.demo

import android.os.Bundle
import android.os.Handler
import androidx.appcompat.app.AppCompatActivity
import org.wenhuayuan.project.main.R
import org.wenhuayuan.uilibrary.refresh.HiRefresh
import org.wenhuayuan.uilibrary.refresh.HiRefreshLayout
import org.wenhuayuan.uilibrary.refresh.HiTextOverView

class RefreshDemoActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_refresh_demo)

        val overView = HiTextOverView(this)
        val refreshLayout = findViewById<HiRefreshLayout>(R.id.refresh_layout)
        refreshLayout.setRefreshOverView(overView)
        refreshLayout.setRefreshListener(object : HiRefresh.HiRefreshListener{
            override fun enableRefresh(): Boolean {
                return true
            }

            override fun onRefresh() {
                Handler().postDelayed({ refreshLayout.refreshFinished() }, 2000)
            }
        })
        refreshLayout.setRefreshDisableScroll(false)
    }
}
